package com.ymatou.iapi.sellerquery.service;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.ymatou.iapi.sellerquery.parameter.resp.CreditInfoListResp;
import com.ymatou.iapi.sellerquery.parameter.resp.GetOrderFlowsResp;
import com.ymatou.iapi.sellerquery.parameter.resp.OrderInfoListResp;
import com.ymatou.iapi.sellerquery.parameter.resp.OrderInfoListResp2;
import com.ymt.base.YmatouBaseCall;
import com.ymttest.common.entitie.OrderInfoForQuery;
import com.ymttest.utils.EnvSetup;

/**
 * 根据订单id列表获取订单列表Call FreeMaker Template自动生成代码
 */
public class GetOrderListByOrderIdListCall extends YmatouBaseCall {
	private static String opurl = "api/SellerQuery/GetOrderListByOrderIdList";

	public GetOrderListByOrderIdListCall() {
		super(EnvSetup.getSystemUrl("sellerquery_iapi"), opurl, "POST", "JSON");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	
	/**
	 * @return
	 */
	public ArrayList<OrderInfoListResp2> getResult() {
		ArrayList<OrderInfoListResp2> result =new ArrayList<OrderInfoListResp2>();
		try {
			String creditlist=new JSONObject(getString("data")).getString("orderInfoList");
			result = (ArrayList<OrderInfoListResp2>) new Gson().fromJson(creditlist, new TypeToken<ArrayList<OrderInfoListResp2>>() {}.getType());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
	

	
	
	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getCode() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("code");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}

	/**
	 * 获取BCode
	 * 
	 * @return
	 */
	public String getBCode() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).getString("bcode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Msg
	 * 
	 * @return
	 */
	public String getMsg() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).getString("msg");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Data
	 * 
	 * @return
	 */
	public JSONObject getData() {
		JSONObject Data = null;
		try {
			Data = new JSONObject(getReturnData()).getJSONObject("data");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Data;
	}

	
	
	/**
 	 * 获取OrderInfoList
 	 * 
 	 * @return
 	 */
 	public List<OrderInfoListResp2> getOrderInfoList(){
 		 List<OrderInfoListResp2> getOrderInfoList=new ArrayList<OrderInfoListResp2>();
 		try {
 			String rd
				 = getData().getString("orderInfoList");
 			Gson gson = new Gson();
 			getOrderInfoList = gson.fromJson(rd, new TypeToken<ArrayList<OrderInfoListResp2>>() {
 			}.getType());
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
 		return getOrderInfoList; 			
 	} 
	
	 
}



